<?php
namespace app\admin\model;
use app\common\BaseModel;

class CateGory extends BaseModel{

	public function add(){
		$this->save((input()));
         return  self::$validate->getError();
	}
	public function Aselect($page,$limit){

		$CateGory = $this->limit(($page-1)*$limit,$limit)->select();
		$total = $this->count();
		return ['code'=>0,'CateGory'=>$CateGory,'total'=>$total,'paginate'=>$this->paginate];
	}

	public function updateCate(){
		 $this->save(input(),['id'=>input('id')]);
         return  self::$validate->getError();
  
	}

	public static function getCategoryName($id){
		$id = intval($id);
		return CateGory::where('id',$id)->value('category_name');
	}
}